package cn.xscrum.demo.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import cn.xscrum.common.annotation.Log;
import cn.xscrum.common.enums.BusinessType;
import cn.xscrum.demo.domain.Huanchengtest;
import cn.xscrum.demo.service.IHuanchengtestService;
import cn.xscrum.common.core.controller.BaseController;
import cn.xscrum.common.core.domain.AjaxResult;
import cn.xscrum.common.utils.poi.ExcelUtil;
import cn.xscrum.common.core.page.TableDataInfo;

/**
 * 换乘优惠大屏可视化Controller
 * 
 * @author xscrum
 * @date 2020-11-26
 */
@Controller
@RequestMapping("/demo/huanchengtest")
public class HuanchengtestController extends BaseController
{
    private String prefix = "demo/huanchengtest";

    @Autowired
    private IHuanchengtestService huanchengtestService;

    @RequiresPermissions("demo:huanchengtest:view")
    @GetMapping()
    public String huanchengtest()
    {
        return prefix + "/huanchengtest";
    }

    /**
	 * 查询换乘优惠大屏可视化列表
     */
    @RequiresPermissions("demo:huanchengtest:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Huanchengtest huanchengtest)
    {
        startPage();
        List<Huanchengtest> list = huanchengtestService.selectHuanchengtestList(huanchengtest);
        return getDataTable(list);
    }

    /**
	 * 导出换乘优惠大屏可视化列表
     */
    @RequiresPermissions("demo:huanchengtest:export")
    @Log(title = "换乘优惠大屏可视化", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Huanchengtest huanchengtest)
    {
        List<Huanchengtest> list = huanchengtestService.selectHuanchengtestList(huanchengtest);
        ExcelUtil<Huanchengtest> util = new ExcelUtil<Huanchengtest>(Huanchengtest.class);
        return util.exportExcel(list, "huanchengtest");
    }

    /**
	 * 新增换乘优惠大屏可视化
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
	 * 新增保存换乘优惠大屏可视化
     */
    @RequiresPermissions("demo:huanchengtest:add")
    @Log(title = "换乘优惠大屏可视化", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(Huanchengtest huanchengtest)
    {
        return toAjax(huanchengtestService.insertHuanchengtest(huanchengtest));
    }

    /**
	 * 修改换乘优惠大屏可视化
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        Huanchengtest huanchengtest = huanchengtestService.selectHuanchengtestById(id);
        mmap.put("huanchengtest", huanchengtest);
        return prefix + "/edit";
    }

    /**
	 * 修改保存换乘优惠大屏可视化
     */
    @RequiresPermissions("demo:huanchengtest:edit")
    @Log(title = "换乘优惠大屏可视化", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(Huanchengtest huanchengtest)
    {
        return toAjax(huanchengtestService.updateHuanchengtest(huanchengtest));
    }

    /**
	 * 删除换乘优惠大屏可视化
     */
    @RequiresPermissions("demo:huanchengtest:remove")
    @Log(title = "换乘优惠大屏可视化", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(huanchengtestService.deleteHuanchengtestByIds(ids));
    }
}
